package com.zjpavt.client.artnet.effect;

import com.zjpavt.client.artnet.device.SingleLight;
import com.zjpavt.client.artnet.device.StripLight;

import java.beans.Transient;

public class SameColorEffect implements IEffect {
    private transient  StripLight stripLight;

    private byte[] color;

    public SameColorEffect(StripLight stripLight, byte[] color) {
        this.stripLight = stripLight;
        this.color = color;
    }

    public SameColorEffect(byte[] color) {
        this.stripLight = stripLight;
        this.color = color;
    }

    public byte[] getColor() {
        return color;
    }

    public void setColor(byte[] color) {
        this.color = color;
    }

    @Override
    public void show() {
        if (stripLight == null) {
            return;
        }
        if (color.length != stripLight.getSingleLightChannelSize()) {
            return ;
        }
        for (SingleLight s :
                stripLight.getLightList()) {
            s.setColor(color);
        }
    }

    @Override
    public void setOwner(StripLight stripLight) {
        this.stripLight = stripLight;
    }
}
